package xyz.xtt.asset.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.response.NftListVo;
import xyz.xtt.asset.enums.SortOrder;
import xyz.xtt.asset.enums.SortType;
import xyz.xtt.asset.service.ITblAssetService;
import xyz.xtt.common.response.ApiResult;

@Tag(name = "首页查询", description = "首页查询")
@Slf4j
@RequestMapping("/api/nft/asset")
@RestController
public class IndexController {

	@Autowired
	private ITblAssetService tblAssetService;

	@GetMapping("/index/list")
	public ApiResult<List<NftListVo>> list(@RequestHeader("uid") Long uid, @RequestParam(value = "type", defaultValue = "1") Integer type, // 1 热卖榜， 2 平台自营， 3
			@RequestParam(value = "currPage", defaultValue = "1") Integer currPage, @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
			@RequestParam(value = "sortType", defaultValue = "") String sortType, @RequestParam(value = "sortOrder", defaultValue = "desc") String sortOrder) {
		log.info("/api/nft/asset//index/list uid:{},type:{},currPage:{},pageSize:{},sortType:{},sortOrder:{}", uid, type, currPage, sortType, sortOrder);
		return ApiResult.ok(tblAssetService.getIndexList(uid, currPage, pageSize, SortType.fromValue(sortType), SortOrder.fromValue(sortOrder)));
	}

}
